#include <stdio.h>

int N = 5;
int cirQueue[5];
int front = -1, rear = -1; 

void enqueue(int x)
{
    if(front == -1)
    {
        front = rear = 0;
        cirQueue[rear] = x;
    }
    else if ((rear+1)%N == front) 
    {
        printf("Queue is FULL!\n");
    }
    else
    {
        rear = (rear + 1)%N;
        cirQueue[rear] = x;
    }
}

void dequeue()
{
    if (front == -1)
        printf("Underflow!\n");
    else if (front == rear)
        front = rear = -1;
    else
    {
        front = (front+1)%N;
    }
}

void peek()
{
    if (front == -1)
    {
        printf("Underflow!\n");
        return;
    }
    printf("%d\n", cirQueue[front]);
}

void display()
{
    if (front == -1)
    {
        printf("Underflow!\n");
        return;
    }  
    int i = front;  
    while (i != rear)
    {
        printf("%d ", cirQueue[i]);
        i=(i+1)%N;
    }
    printf("%d \n", cirQueue[rear]);
}

int main()
{
    enqueue(2);
    enqueue(-1);
    enqueue(5);
    enqueue(6);
    enqueue(7);
    display();
    dequeue();
    dequeue();
    enqueue(0);
    enqueue(10);
    display();
}